package com.qianli.cashmama.trade.dao.impl;

import com.fqgj.common.datasource.DynamicSqlSessionDaoSupport;
import com.qianli.cashmama.trade.dao.TChannelCodeMappingDao;
import com.qianli.cashmama.trade.entity.TChannelCodeMappingEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * User: liuming
 * Date: 2019-03-27
 * Time: 20:07:18.058
 */

@Repository
public class TChannelCodeMappingDaoImpl extends DynamicSqlSessionDaoSupport implements TChannelCodeMappingDao {

    protected String getStatement(String sqlId) {
        String name = getClass().getName();
        StringBuilder sb = new StringBuilder();
        if (sqlId.contains(".")) {
            sb.append(name).append(sqlId);
            return sb.toString();
        } else {
            sb.append(name).append(".").append(sqlId);
            return sb.toString();
        }
    }

    @Override
    public List<TChannelCodeMappingEntity> selectAllChannel() {
        return getSqlSession().selectList(getStatement("selectAllChannel"));
    }

    @Override
    public void insert(TChannelCodeMappingEntity entity) {
        getSqlSession().insert(getStatement("insert"), entity);
    }
}